package com.yupi.springbootinit.BiMQ.Test;

import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.stereotype.Component;

import java.io.IOException;



@Slf4j
public class TestConsumer {
    @RabbitListener(queues = {"my_queue"},ackMode = "MANUAL")
    public void receive(String message, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long deliveryTag){
        log.info("发送的消息为message===>:{}",message);
        try {
            channel.basicAck(deliveryTag,false);
        } catch (IOException e) {
            log.info("messageThrow{}",e.getMessage());
            throw new RuntimeException(e);
        }
    }
}
